/*
 * @Descripttion:
 * @version:
 * @Author: xcb
 * @Date: 2021-04-02 09:52:31
 * @LastEditors: gzy 810461372@qq.com
 * @LastEditTime: 2023-09-04 16:22:20
 */
import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
  RouteRecordRaw,
} from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    component: () => import("../views/planMenu.vue"),
    children: [
      // 一维列表
      {
        path: "sedimentScheme_manage",
        name: "sedimentScheme_manage",
        component: () => import("../views/PlanList.vue"),
      },
      // 历史预报
      {
        path: "sedimentForecast",
        name: "sedimentForecast",
        component: () => import("../views/Forecast.vue"),
      },
      // 参数方案列表
      {
        path: "paramsList",
        name: "paramsList",
        component: () =>
          import("../views/paramPlanManage/paramManage/paramsList.vue"),
      },
      // 参数方案预设
      {
        path: "paramsAdd",
        name: "paramsAdd",
        component: () =>
          import("../views/paramPlanManage/paramManage/paramsAdd.vue"),
      },
      // 初始化参数列表
      {
        path: "mainDataList",
        name: "mainDataList",
        component: () =>
          import("../views/paramPlanManage/mainDataManage/mainDataList.vue"),
      },
      // 初始化参数预设
      {
        path: "mainDataAdd",
        name: "mainDataAdd",
        component: () =>
          import("../views/paramPlanManage/mainDataManage/mainDataAdd.vue"),
      },
      // 泥沙参数列表
      {
        path: "sedParamDataList",
        name: "sedParamDataList",
        component: () =>
          import(
            "../views/paramPlanManage/sedParamDataManage/sedParamDataList.vue"
          ),
      },
      // 泥沙参数预设
      {
        path: "sedParamDataAdd",
        name: "sedParamDataAdd",
        component: () =>
          import(
            "../views/paramPlanManage/sedParamDataManage/sedParamDataAdd.vue"
          ),
      },
      // 河道糙率列表
      {
        path: "mainStreamDataList",
        name: "mainStreamDataList",
        component: () =>
          import(
            "../views/paramPlanManage/roughnessDataManage/mainStreamDataList.vue"
          ),
      },
      // 河道糙率预设
      {
        path: "mainStreamDataAdd",
        name: "mainStreamDataAdd",
        component: () =>
          import(
            "../views/paramPlanManage/roughnessDataManage/mainStreamDataAdd.vue"
          ),
      },
      // 水位预报
      {
        path: "/swForecast",
        name: "swForecast",
        component: () => import("../views/swForecast.vue"),
      },
      // 水位预报
      {
        path: "/modelFormulasList",
        name: "modelFormulasList",
        component: () => import("../views/modelFormulas/modelFormulasList.vue"),
      },
      // 水位预报
      {
        path: "/modelFormulasAdd",
        name: "modelFormulasAdd",
        component: () => import("../views/modelFormulas/modelFormulasAdd.vue"),
      },
      // 水位预报
      {
        path: "/rainModelList",
        name: "rainModelList",
        component: () => import("../views/rainModel/rainModelList.vue"),
      },
      // 水位预报
      {
        path: "/rainModelAdd",
        name: "rainModelAdd",
        component: () => import("../views/rainModel/rainModelAdd.vue"),
      },
    ],
  },
  // 地图
  {
    path: "/Map",
    name: "Map",
    component: () => import("../views/map/Map.vue"),
  },
  // 方案创建
  {
    path: "/schemePreset",
    name: "schemePreset",
    component: () => import("../views/schemePreset/index.vue"),
  },
];

const router = createRouter({
  history: createWebHashHistory("/sad-dis"),
  routes: routes,
});

if (import.meta.hot) {
  let removeRoutes = [];

  for (let route of routes) {
    removeRoutes.push(router.addRoute(route));
  }

  import.meta.hot.accept("./routes.js", ({ routes }) => {
    for (let removeRoute of removeRoutes) removeRoute();
    removeRoutes = [];
    for (let route of routes) {
      removeRoutes.push(router.addRoute(route));
    }
    router.replace("");
  });
}
export default router;
